package com.he.eduservice.controller.front;

import com.he.commonutils.R;
import com.he.eduservice.entity.EduCourse;
import com.he.eduservice.entity.EduTeacher;
import com.he.eduservice.service.EduCourseService;
import com.he.eduservice.service.EduTeacherService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(description = "查询前台首页的讲师和热门课程")
@RestController
@CrossOrigin
@RequestMapping("/edu/front")
public class FrontInfoController {

    @Autowired
    private EduTeacherService teacherService;

    @Autowired
    private EduCourseService courseService;

    @GetMapping("/findTeacherList")
    public R findTeacherList() {
        List<EduTeacher> result = teacherService.findTeacherList();
        return R.ok().data("list", result);
    }

    @GetMapping("findCourseList")
    public R findCourseList(){
        List<EduCourse> result = courseService.findCourseList();
        return R.ok().data("list", result);
    }
}
